package com.emep.changzhi.analyse.service.Technology;


import com.emep.changzhi.analyse.entity.Technology.Denitrification;
import com.emep.changzhi.analyse.entity.datamonitor.day.DataDayAirquality;
import com.emep.changzhi.analyse.repository.Technology.DenitrificationRepository;
import com.emep.changzhi.analyse.utils.MapUtils;
import com.emep.changzhi.analyse.utils.UUIDTest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 脱销服务层
 */
@Slf4j
@Service
public class DenitrificationService {


    @Autowired
    private   DenitrificationRepository repository;

    /**
     *
     * 新增
     *
     * @param payload
     * @return
     * @throws Exception
     */
    public Denitrification save(Map<String, Object> payload) {

        Denitrification desulphurization = null;
        try {
            Denitrification desulphurization1 = (Denitrification) MapUtils.convertMap(Denitrification.class,payload);
            desulphurization1.setId(UUIDTest.getUUID());
            desulphurization = repository.save(desulphurization1);
        } catch (Exception e) {
            log.error(e.getClass().getName() + ":" + e.getMessage());
            log.error(e.getLocalizedMessage());
        }
        return desulphurization;
    }

    /**
     *
     * @Description: 首页
     * @date 2018/3/8 10:11
     * @version V1.0
     */
    public List<Denitrification> findDataByHome(Integer pageSize){
        List<Denitrification> airQualitys = null;
        try {
            airQualitys = repository.denitrificationHome(pageSize);
        }catch (Exception e){
            log.error(e.getClass().getName()+":"+ e.getMessage());
            log.error(e.getLocalizedMessage());
        }
        return airQualitys;

    }
    /**
     *
     * @Description: 翻页查询
     * @date 2018/3/8 10:18
     * @version V1.0
     */

    public List<Denitrification> findDataByFlip(String id,Integer pageSize) {
        List<Denitrification> airQualitys = null;
        try {
            airQualitys = repository.denitrificationFlip(id,pageSize);
        }catch (Exception e){
            log.error(e.getClass().getName()+":"+ e.getMessage());
            log.error(e.getLocalizedMessage());
        }
        return airQualitys;
    }




}
